package lee.base.xmlformat;

import lee.base.constant.Symbol;
import lee.base.constant.XmlAttribute;
import lee.base.structure.MyHashTree;
import lee.base.structure.MyNode;
import lee.base.structure.Position;
import lee.base.structure.Size;

public class BaseFormat {
	
	public static Size getSize(MyHashTree tree, MyNode nodeHead) {
		String splitPoint = XmlAttribute.VARIABLE_POINT + "";
		String head = nodeHead.GET003_attribute() + splitPoint + "size" + splitPoint;
		String getW = tree.ACT002_getSpecificValue(head + "width", nodeHead);
		String getH = tree.ACT002_getSpecificValue(head + "height", nodeHead);
		return new Size(Integer.parseInt(getW), Integer.parseInt(getH));
	}
	
	public static Position getPosition(MyHashTree tree, MyNode nodeHead, boolean screenType) {
		String splitPoint = XmlAttribute.VARIABLE_POINT + "";
		String posAttrName = null;
		if(screenType == Symbol.SCREEN_HORIZENTAL) {
			posAttrName = "pos_horz";
		}
		else if(screenType == Symbol.SCREEN_VERTICAL) {
			posAttrName = "pos_vert";
		}
		String head = nodeHead.GET003_attribute() + splitPoint + posAttrName + splitPoint;
		String getX = tree.ACT002_getSpecificValue(head + "x", nodeHead);
		String getY = tree.ACT002_getSpecificValue(head + "y", nodeHead);
		return new Position(Integer.parseInt(getX), Integer.parseInt(getY));
	}
}
